package com.shhm.business.dto.request;

import jakarta.annotation.Resource;
import lombok.Data;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author JackZ
 * @version 1.0
 * @description: TODO
 * @date 2025/9/14 下午1:30
 */
@Data
public class SubmitOrderReq implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    private String orderNum;
    private Integer dataVersion;
    private String userPassword;

    /**
     * 订单提交类型。1:提交订单 2:取消订单
     */
    private Integer submitType;

    /**
     * 系统生成字段
     */
    private Integer beforeOrderStatus;
    private Integer afterOrderStatus;
    private LocalDateTime payTime;

    private String successTips;
    private String failTips;

    public void operateType(){
//        支付订单
        if (submitType==1) {
            this.beforeOrderStatus = 0;
            this.afterOrderStatus = 1;
            this.successTips="支付成功";
            this.failTips="支付失败";
            this.payTime=LocalDateTime.now();
        }
        //取消订单
        else if (submitType==2) {
            this.beforeOrderStatus = 0;
            this.afterOrderStatus = 4;
            this.successTips="您已取消订单";
            this.failTips="取消订单失败";
        }
//        提交收货
        else if(submitType==3){
            this.beforeOrderStatus = 1;
            this.afterOrderStatus = 2;
            this.successTips="操作成功";
            this.failTips="操作失败";
        }
//        其他操作
        else{
            this.beforeOrderStatus = -1;
            this.afterOrderStatus = 0;
            this.successTips="无效操作";
            this.failTips="无效操作";
        }
    }

}
